//network/api.js文件
import base from './baseUrl.js'
import Request from './request.js'
import RequestQQT from './request_qqt.js'
let request = new Request().http
let request_qqt = new RequestQQT().http

function get(url, data, whetherData = true, hideLoading, header) {
	return request({
		url: url,
		method: 'GET',
		data: data,
		header: header,
		whetherData: whetherData
	})
}

function post(url, data, whetherData = true, hideLoading, header) {
	return request({
		url: url,
		method: 'POST',
		data: data,
		header: header,
		whetherData: whetherData,
		hideLoading: hideLoading,
	})
}

//图片传输地址 地址
function uploadPhoto(tempFilePaths, yes, no) {
	// 上传图片
	uni.uploadFile({
		url: base.uploadImgUrl, //开发者服务器 url
		header: {
			// HTTP 请求 Header, header 中不能设置 Referer
			Token: uni.getStorageSync("token")
		},
		filePath: tempFilePaths, // 要上传文件资源的路径
		name: 'file', // 文件对应的 key , 开发者在服务器端通过这个 key 可以获取到文件二进制内容
		formData: {
			// HTTP 请求中其他额外的 form data （即接口需要的其它参数）
		},
		success(res) {
			console.log('上传成功', res);
			yes(res);
		},
		fail() {
			console.log('失败', err);
			no(err);
		},
		complete() {
			console.log('结束');
		},
	})
}

function get_qqt(url, data, whetherData = true, hideLoading, header) {
	return request_qqt({
		url: url,
		method: 'GET',
		data: data,
		header: header,
		whetherData: whetherData
	})
}

function post_qqt(url, data, whetherData = true, hideLoading, header) {
	return request_qqt({
		url: url,
		method: 'POST',
		data: data,
		header: header,
		whetherData: whetherData,
		hideLoading: hideLoading,
	})
}

let api = {

	/**
	 * start------司机端接口迭代版本20240924
	 */
	// 查询车次信息(qqt)
	getTrcukDetail: data => get_qqt('/api/Pda/transferdetail', data, true, true),

	// 订单列表(shwl) 
	getOrderList: data => post('/api/order/list', data, true, true),

	// 生成建行支付二维码(qqt)
	genCCBQrCode: data => post_qqt('/api/CCB/Create_CCB_QR', data, true,
		true, { 'Content-Type': 'application/json' }),

	// 建行交易查询 
	post_ccb_status: data => post_qqt('/api/CCB/Get_CCB_QR_STATUS', data, true,
		true, { 'Content-Type': 'application/json' }),

	// 大车直送扫码出库 同步全球通运单状态
	post_autopickup: data => post_qqt('/api/Pda/autopickup', data, true,
		true, { 'Content-Type': 'application/json' }),


	/**
	 * 司机端接口迭代版本20240924------end
	 */


	/*
	 *  ================版本号=================
	 */
	mine_getVersion: data => post('app/version', data, false, true),
	uploadPhoto: (data, yes, no) => uploadPhoto(data, yes, no),
	//  *  ================登录=================
	// // app登录
	driverLogin: data => post('/api/user/driverLogin', data, true, true),
	// 信息提交(司机确认分享信息)
	confirm: data => post('/api/share/confirm', data, true, true),
	// 获取用户信息
	userInfo: data => post('/api/user/userinfo', data, true, true),
	// 修改会员个人信息
	edituserInfo: data => post('/api/user/profile', data, true, true),
	logout: data => post('/api/user/logout', data, true, true),

	userCarAdd: data => post('/api/user/userCarAdd', data, true, true),
	userCarList: data => post('/api/user/userCarList', data, true, true),
	userCarEdit: data => post('/api/user/userCarEdit', data, true, true),
	userCarDelete: data => post('/api/user/userCarDelete', data, true, true),
	userCarInfo: data => post('/api/user/userCarInfo', data, true, true),


	// 银行卡 -----------------------------------------------

	//获取默认银行卡
	bank_getdefault: data => post('/api/bank/getdefault', data, true, true),

	//银行列表
	bank_lists: data => post('/api/bank/lists', data, true, true),

	//添加银行卡
	bank_add: data => post('/api/bank/add', data, true, true),

	//删除银行卡
	bank_del: data => post('/api/bank/del', data, true, true),

	//修改银行卡
	bank_edit: data => post('/api/bank/edit', data, true, true),

	//设置默认银行卡
	bank_setdefault: data => post('/api/bank/setdefault', data, true, true),

	//申请车费----------------------------------------------
	//申请车费 申请记录
	Freight_lists: data => post('/api/Freight/lists', data, true, true),
	//申请车费
	Freight_apply: data => post('/api/Freight/apply', data, true, true),
	// 车费申请
	freightaddAmount: data => post('/api/Freight/addAmount', data, true, true),
	// 车费申请列表
	freightaddAmountList: data => post('/api/Freight/addAmountList', data, true, true),

	// 运单订单 ----------------------------------------------

	//运费垫资列表
	order_dianzilist: data => post('/api/order/dianzilist', data, true, true),

	//运单列表
	Waybill_lists: data => post('/api/Waybill/lists', data, true, true),

	//订单列表
	order_lists: data => post('/api/order/lists', data, true, true),

	//确认发车
	waybill_fache: data => post('/api/waybill/fache', data, true, true),

	//订单详情
	order_info: data => post('/api/order/info', data, true, true),

	//订单确认到达
	order_confirm: data => post('/api/order/confirm', data, true, true),

	//订单确认不配送
	order_noDelivery: data => post('/api/order/noDelivery', data, true, true),

	//设置需要配送的总运费
	order_save_delivery_amount: data => post('/api/order/save_delivery_amount', data, true, true),



	// 首页---------------------------------------------------

	//首页
	index_index: data => post('/api/index/index', data, true, true),

	//扫一扫填车牌
	index_getlineinfo: data => post('/api/index/getlineinfo', data, true, true),

	//获取车辆信息
	cars_Info: data => post('/api/cars/Info', data, true, true),

	// 补充司机信息确认
	cars_restock: data => post('/api/cars/restock', data, true, true),
	// 发送短信
	index_sendSms: data => post('/api/index/sendSms', data, true, true),
	// 扫码填过信息确认
	cars_confirm: data => post('/api/cars/confirm', data, true, true),
	// 首页未结算的订单
	getCarOrder: data => post('/api/index/getCarOrder', data, true, true),

	// ---------------------------------------------------------

	// 途中事故上报
	Accident_add: data => post('/api/Accident/add', data, true, true),

	//订单列表
	orderlists: data => post('/api/order/lists', data, true, true),


	//司机接单页面---------------------------------------------
	share_receiving: data => post('/api/share/receiving', data, true, true),


	//申请保证金记录-------------------------------------------
	bond_lists: data => post('/api/bond/lists', data, true, true),

	bond_info: data => post('/api/bond/info', data, true, true),

	//申请保证金
	bond_apply: data => post('/api/bond/apply', data, true, true),

	//上传车辆定位
	Carslocation_add: data => post('/api/Carslocation/add', data, true, true),

	//保证金缴纳
	create_bond_order: data => post('/api/bond/create_bond_order', data, true, true),

	// 获取需要配送的订单
	get_delivery_list: data => post('/api/order/get_delivery_list', data, true, true),

	// 用户协议
	userAgreement: data => post('/disapi/Agreement/user', data, true, true),
	// 隐私协议
	privacyAgreement: data => post('/disapi/Agreement/privacy', data, true, true),

	//获取车辆信息
	getCarInfo: data => post('/api/cars/get_car_info', data, true, true),

	// // app注册
	// login_regist: data => post('login/regist', data, true, true),
	// /*
	//  *  ================我的=================
	//  */
	// 我的
	// info:data=>post('user/info',data,true,true),

	// 兑换商品-提交订单
	// submitOrder: data => post('change/submitOrder', data, true, true, Object.assign({
	//   'content-type': "application/json"
	// })),

}

export default api;